<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="/res/include/base-head.jsp"%>
<%@include file="/res/include/jquery-easyui.jsp"%>
<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/user/userSuggest.js"></script>
</head>
<body>
	<div class="form_item">
		<dl>
			<dt>用户：</dt>
			<dd>
				<c:out value='${detail.nick}' />
			</dd>
		</dl>
		<dl>
			<dt>内容：</dt>
			<dd>
				<c:out value='${detail.content}' />
			</dd>
		</dl>
		<c:if test="${detail.hasImg}">
			<dl>
				<dt>图片：</dt>
				<dd>
					<ul class="product_imglist img_imglist">
						<c:forEach items="${detail.imgItems}" var="img" >
							<li><p class="bigImg"><a href="javascript:void(0);" onclick="showBigImg('${img.source}')"><img src="${img.source}" alt="" /></a></p></li>
						</c:forEach>
					</ul>
				</dd>
			</dl>
		</c:if>
		<dl>
			<dt>时间：</dt>
			<dd>
				<c:out value='${detail.strNewAt}' />
			</dd>
		</dl>
		<c:if test="${detail.isReply==1}">
		<dl>
			<dt>回复：</dt>
			<dd>
				<ul class="product_imglist img_imglist">
					<c:forEach items="${replys}" var="item" >
						<li>
						<c:out value='${item.content}' />
						<c:if test="${item.hasImg}">
							<c:forEach items="${item.imgItems}" var="img" >
								<p class="img"><img src="${img.source}" alt="" /></p>
							</c:forEach>
						</c:if>
						</li>
					</c:forEach>
				</ul>
			</dd>
		</dl>
		</c:if>
		<c:if test="${detail.isReply==2}">
		<dl>
			<dt>回复内容：</dt>
			<dd>
				<textarea rows="5" cols="50" id="content"></textarea>
			</dd>
		</dl>
		<dl>
			<dt>回复图片：</dt>
			<dd>
				<ul class="product_imglist img_imglist_add">
					<c:forEach begin="0" end="4" varStatus="i">
						<li><a href="javascript:;" class="item" id="pic${i.index}" onclick="admin.userSuggest.addImg('pic${i.index}')">添加图片</a>
						</li>
					</c:forEach>
				</ul>
				<em class="p0">上传4:3的JPG/PNG/BMP图片，建议：720*540px</em>
			</dd>
		</dl>
		<p class="page_btn">
			<input type="button" value="回复" class="btn_blue" onclick="doReply();" />
		</p>
		</c:if>
	</div>
</body>
<script type="text/javascript">
	function showBigImg(url){
		top.addTab("",'图片', url);
	}
	//提交保存
	var isSave = false;
	function doReply() {
		var img = "";
		var content=$("#content").val();
		var imglist = $(".img_imglist_add img");
		if (imglist && imglist.length > 0) {
			imglist.each(function() {
				if (img == "") {
					img += $(this).attr("src").replace(imgFilePath, "");
				} else {
					img += ";" + $(this).attr("src").replace(imgFilePath, "");
				}
			});
		}
		if(null==content||''==content){
			top.showInfo('请填写回复内容');
			return;
		}
		var url = contextPath + '/user/suggest/replay/add';
		if (!$('#data-form').form('validate'))
			return;
		if (isSave) {
			return;
		}
		isSave = true;
		var data = $('#data-form').form('jsonObject');
		data.img = img;
		data.suggestId = '${detail.id}';
		data.content=content;
		$.post(url, data, function(result) {
			if (result.code == 1) {
				top.showInfo('保存成功');
				top.addTab("",'问题与建议记录', contextPath+'/user/suggest/list');
			} else {
				isSave = false;
				top.showInfo('保存失败:' + result.msg);
			}
		}, 'json');
	}
</script>
</html>
